package lg.minecraft.plugin.worldprotect.config;

import lg.minecraft.plugin.library.config.LGBaseConfig;
import lg.minecraft.plugin.worldprotect.LGWorldProtect;
import lg.minecraft.plugin.worldprotect.WorldSettingType;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * @author langle__
 * @version 1.0
 */
public class Language extends LGBaseConfig {

    private final Map<WorldSettingType, String> NAME = new HashMap<>();
    private final Map<WorldSettingType, String> Description = new HashMap<>();
    private final Map<WorldSettingType, String> TIP = new HashMap<>();

    @Getter private String prefix = "[§6WorldProtect§f] ";
    @Getter private String enable = "§a启用";
    @Getter private String disable = "§c禁用";

    public Language() {
        super(LGWorldProtect.getInstance(), "language");
        this.init();
    }

    @Override
    public void load() {
        super.load();
        prefix = this.getString("prefix");
        enable = this.getString("enable");
        disable = this.getString("disable");
        for (WorldSettingType value : WorldSettingType.values()) {
            String name = value.name().toLowerCase();
            NAME.put(value, this.getString("WorldSetting." + name + ".name"));
            Description.put(value, this.getString("WorldSetting." + name + ".description"));
            String tip = this.getString("WorldSetting." + name + ".tip");
            if (tip == null) continue;
            tip = tip.replace("%prefix%", prefix);
            TIP.put(value, tip);
        }
    }

    public String getWorldSettingName(WorldSettingType setting) {
        return NAME.get(setting);
    }

    public String getWorldSettingDescription(WorldSettingType setting) {
        return Description.get(setting);
    }

    public String getWorldSettingTip(WorldSettingType setting) {
        return TIP.get(setting);
    }

}
